How joins affect the result set in a query

If your query contains more than one table, you can create a "join" between the two tables. Two tables are connected by a join line; the line shows Microsoft Query how the data is related. The type of join is important because it indicates which records Microsoft Query selects and includes in the result set of your query.

An inner join — the default join type — selects only records that have the same value in the joined fields in both tables. Microsoft Query combines the two matching records from each table and displays them as one record in the query result set. If one record doesn't have a matching record in the other table, neither record appears in the result set. For example, the following illustration shows an inner join for Customer ID. Query returns records whose Customer ID in Orders:Table matches the Customer ID in Customers:Table.

Example of an inner join

You can also create an outer join, which selects records that are not equivalent. When you create an outer join, Microsoft Query selects all the records from one table whether or not there are matching records in the other table. When values in the two tables are the same, Microsoft Query combines the matching records and displays them as one record in the query result set. When a record from the table that's contributing all of its records can't be matched with a record from the other table, the record still appears in the result set. However, Microsoft Query displays empty cells where no matching record occurred in the other table.

Example of an outer join

Related topics

Create a join

Change the type of join between tables in a query

Combine all the data from two tables

Retrieve the records that two tables don't have in common